<%@ page isELIgnored="false" %>
<%@page import="java.util.Random"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<base href="/shopping/views/">
<head>
	<title>登录</title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link href="front/css/bootstrap.min.css" rel="stylesheet" type="text/css">
	<link href="front/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css">
	<link href="front/css/templatemo_style.css" rel="stylesheet" type="text/css">	
</head>
<body style="background:rgba(0,0,0,.5);">
	<div class="container" style="position:relative;top:10px;">
		<div class="col-md-12">			
			<form class="form-horizontal templatemo-create-account templatemo-container"  action="" method="post">
			        <div class="form-group">
			          <div class="col-md-6">	       	
			            <label for="username" class="control-label">用户名/手机号</label>
			            <input type="text" class="form-control" name="searchParam" id="username" placeholder="" onBlur="checkUserName()">		         		            		  
                          <span id="userName_warn"></span>     
			          </div>
			        </div>
					<div class="form-group">
			          <div class="col-md-6">
			            <label for="password" class="control-label">密码</label>
			            <input type="password" class="form-control" name="upwd" id="password" placeholder="" onBlur="checkPassword()" required="required">
                         <span id="password_warn"></span>  
			          </div>
			        </div>
                    
			        <div class="form-group">
			          <div class="col-md-12">
			            <input type="button" value="登录" class="btn btn-info" onClick="login()" id="loginUser" >
			            <input type="button" value="取消" class="btn btn-danger" id="cancalLogin" onClick="javascript:window.parent.close_div('loginDIV')" >
                          <!--这里也是跨域调用的js方法-->
			            <a href="javascript:window.parent.close_div('loginDIV');window.parent.open_div('registerDIV')" class="pull-right">立即注册</a>
			          </div>
			        </div>					    	
		      </form>		      
		</div>
	</div>
	<!-- Modal -->
	<!--<div class="modal fade" id="templatemo_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
	        <h4 class="modal-title" id="myModalLabel">使用协议</h4>
	      </div>
	      <div class="modal-body">
	      	<p>中文中文</p>
		  </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
	      </div>
	    </div>
	  </div>
	</div>-->
	<script type="text/javascript" src="front/js/jquery-1.11.1.min.js"></script>
	<script type="text/javascript" src="front/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="front/js/register.js"></script>
    <script type="text/javascript">
//  //发送验证码
//    var time=120;
//    function f1(){
//    	$("#YZcode").val(time+" s后重发");
//    	time--;
//    	if(time<=0){
//    		window.clearInterval();
//    		$("#YZcode").val("验证超时");
//    		
//    	}
//    }
//    function YZcodee(){
//    	$.post("user/sendEMail",{"email":$("#first_name").val()},function(data){
//    		alert(data);
//    	})
//    	window.setInterval("f1()", 1000);
//    	if(time<=0){
//    		window.clearInterval();
//    		$("#YZcode").val("重新获取验证码");
//    		time=120;
//    	}
//    	
//    }
    
    // 登录的方法
    function login(){
        $.ajax({
            url:'../front/user/login',
            data:$("form").serialize(),
            type:'POST',
            dataType:'JSON',
            success:function(data){
                if(data.code=='0000'){
                    alert('success');
                    var shopCarCount=0;
                    //登录成功
                    //TODO:关闭这个登录的iframe  
                    window.parent.close_div('loginDIV');//这个的是在index.jsp 页面里面引用的js的里面的一个方法，这里是跨域调用js方法，
                    //然后把父级的头的部分修改一下
                    //这里是跨域 取到 document对象
                    $("#user_head",parent.document).html('<ul class="list-inline pull-right">Hi,<li><a href="javascript:toUserInfo()" ><i class="fa fa-user"></i>'+data.obj.uname+'</a></li><li><a href="javascript:toShopCar()" ><i class="fa fa-heart-o"></i> 购物车 (${shopCarCount})</a></li><li><a class="exit" href="javascript:exit()" >登出</a></li> </ul>');
                }else{
                    //登录失败
                    alert(data.msg);
                }
            }
        });
    }
    
    </script>
</body>
</html>